<?php
/**
 * User: Niuxitong
 * Date: 2021/1/8 9:20
 */
namespace app\api\controller;

use addons\txim\TLSSigAPI;
use app\common\controller\Api;
use think\Cache;
use think\Db;
use think\Session;


class Conference extends Api
{
    //如果$noNeedLogin为空表示所有接口都需要登录才能请求
    //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
    //如果接口已经设置无需登录,那也就无需鉴权了
    //无需登录的接口,*表示全部
    protected $noNeedLogin = ['entry', 'info', 'config', 'verify', 'status', 'pubmsg', ];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ["*"];

    /**
     * 正式 加入活动
     * https://my.local-onzoom.cn/api/conference/config?conf_id=670235891&token=0fc21aae-4c8b-406c-a479-af1fb6f8a1d8&lang=zh-CN
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function config()
    {
        $params = $this->request->param();
        if ($params) {
            $params['conf_id'] = trim($params['conf_id']);
            $serialNumber = isset($params['serialNumber']) ? str_replace(' ', '', $params['serialNumber']) : '';
            //活动主表信息
            $confObj = Db::name('activity')->where('serial', $params['conf_id'])->find();
            if (!$confObj) {
                $this->error("活动不存在！");
            }
            // 兼容会议系统，新增字段 niuxitong 2021-01-21
            $confObj['mainVideo'] = 1;                  //主持人视频:0=关闭,1=开启
            $confObj['mainAudio'] = 1;                  //主持人音频:0=关闭,1=开启
            $confObj['participantVideo'] = 1;           //参与者视频:0=关闭,1=开启
            $confObj['participantAudio'] = 1;           //参与者音频:0=关闭,1=开启
            $confObj['normalPassword'] = '';            //会议密码（后台用户添加是，可以设置可以不设置）
            $confObj['mainPassword'] = 'abcd';          //主持人密码
            $confObj['mode'] = 'freeCamera';            //会议模式:freeCamera=自由视角,mainBroadcast=与主持人广播视频一致,mainCamera=与主持人视角一致,intercom:对讲模式,voiceSeminar:语音讨论会议,trainingConference:在线培训会议,EHSfieldOperation:EHS现场作业,multilingualTranslation:多语言翻译
            $confObj['lock'] = intval($confObj['status']) == 1 ? 0 : 1;                     //会议状态:0=未锁定,1=锁定，与活动表activity的status字段对应
            $confObj['share_image'] = empty($confObj['thumb']) ? '': $confObj['thumb'];     //分享图片（可以使用封面图）
            $endTime = intval($confObj['startTime']) + intval($confObj['duration']);
            $confObj['endTime']  = '2030-01-01 00:00:00';                                   //结束时间，暂且使用长期， 正确的方式是：date('Y-m-d H:i:s', $endTime);
            $confObj['startTime']  = date('Y-m-d H:i:s', $confObj['startTime']);     //开始时间
            //pr($confObj, 1);
            //获取会议的所有者 信息
            $user = Db::name("admin")->where('id',$confObj['admin_id'])->find();
            if ($user['status'] != "normal") {
                $this->error("活动已失效");
            }
            if (!$user['admin_tag']){
                $user['admin_tag'] = 'null';
                $user['validity_time'] = "2000-01-01 00:00:00";         //有效期
            }
            $noSlash = isset($params['noSlash']) ? $params['noSlash'] : false;          // 是否加密：

            // 获取缓存中的剩余服务器
            $cacheType = config('cache.redis') ? 'redis' : '';
            $allServerAddress = Cache::store($cacheType)->get(config('redis_prefix').'ServerAddress'."-admin_tag-".$user['admin_tag']);
            if (!$allServerAddress) {
                $serverAddressObj = new \app\admin\model\ServerAddress;
                $allServerAddress = [];
                $user_tags_service = Db::name('server_grouping')->whereLike("tag_ids",'%'.$user['admin_tag'].'%')->find();
                $serverAddressSQLdata = $serverAddressObj->where("distinguish",$user_tags_service['id'])->select();
                if (!$serverAddressSQLdata){
//                    $serverAddressSQLdata = $serverAddressObj->distinct(true)->select();
                    $serverAddressSQLdata = $serverAddressObj->where('distinguish is null')->select();
                }
                foreach ($serverAddressSQLdata as $sqldata) {
                    $addressInfo = [];
                    $addressInfo["intranet_address"] = $sqldata['intranet_address'];
                    $addressInfo["external_address"] = $sqldata["external_address"];
                    $addressInfo["encrypted_extranet"] = $sqldata["encrypted_extranet"];
                    $addressInfo["encrypted_intrane"] = $sqldata["encrypted_intrane"];
                    $allServerAddress[] = $addressInfo;
                }
            }

            // 查询会议ID是否已分配会议地址
            $ConfServerAddress = Cache::store($cacheType)->get(config('redis_prefix').'ConfServerAddress:' . $params['conf_id']);
            if ($ConfServerAddress) {
                $seradd = $ConfServerAddress;
            } else {
                $seradd = array_shift($allServerAddress);
                Cache::store($cacheType)->set(config('redis_prefix').'ConfServerAddress:' . $params['conf_id'], $seradd, 0);
                Cache::store($cacheType)->set(config('redis_prefix').'ServerAddress'."-admin_tag-".$user['admin_tag'], $allServerAddress, 0);
            }

            $host = $this->request->host();
            $scheme = $this->get_scheme();   // 获取 https  $scheme = adminApi::get_scheme();

            if (isset($params['encrypted'])) {
                $encrypted = $params['encrypted'];
            } else {
                if ($scheme == "https") {
                    $encrypted = 1;
                } elseif ($scheme == "http") {
                    $encrypted = 0;
                } else {
                    $encrypted = 1;
                }
            }

            if (isset($params['intranet'])) {
                $intranet = $params['intranet'];
                if ($intranet == "external") {
                    if ($encrypted) {
                        $addressInfo = $seradd['encrypted_extranet'];
                    } else {
                        $addressInfo = $seradd['external_address'];
                    }
                } else {
                    if ($encrypted) {
                        $addressInfo = $seradd['encrypted_intrane'];
                    } else {
                        $addressInfo = $seradd['intranet_address'];
                    }
                }

            } else {
                // 加密
                if ($encrypted) {
                    $encryptedIntrane = explode(":", $seradd['encrypted_intrane']);
                    $encryptedIntrane = $encryptedIntrane[1];
                    $encryptedIntrane = explode("//", $encryptedIntrane);
                    $encryptedIntrane = $encryptedIntrane[1];
                    $encryptedExtranet = explode(":", $seradd['encrypted_extranet']);
                    $encryptedExtranet = $encryptedExtranet[1];
                    $encryptedExtranet = explode("//", $encryptedExtranet);
                    $encryptedExtranet = $encryptedExtranet[1];
                    if ($host == $encryptedExtranet) {
                        $addressInfo = $seradd['encrypted_extranet'];
                    } elseif ($host == $encryptedIntrane) {
                        $addressInfo = $seradd['encrypted_intrane'];
                    } else {
                        $addressInfo = $seradd['encrypted_extranet'];
                    }
                } else {  // 不加密
                    $intranetAddress = explode(":", $seradd['intranet_address']);
                    $intranetAddress = $intranetAddress[1];
                    $intranetAddress = explode("//", $intranetAddress);
                    $intranetAddress = $intranetAddress[1];
                    $externalAddress = explode(":", $seradd['external_address']);
                    $externalAddress = $externalAddress[1];
                    $externalAddress = explode("//", $externalAddress);
                    $externalAddress = $externalAddress[1];
                    if ($host == $intranetAddress) {
                        $addressInfo = $seradd['intranet_address'];
                    } elseif ($host == $externalAddress) {
                        $addressInfo = $seradd['external_address'];
                    } else {
                        $addressInfo = $seradd['external_address'];
                    }
                }
            }

            if ($noSlash == true) {
                if (substr($addressInfo, -1) == '/') {
                    $addressInfo = substr($addressInfo, 0, strlen($addressInfo) - 1);
                }
            } else {
                if (substr($addressInfo, -1) != '/') {
                    $addressInfo = $addressInfo . "/";
                }
            }

            // $configinfo   获取会议相关配置信息
            $configinfo = [];
            $configinfo['neednormalPassword'] = 0;      //是否需要会议室密码
            $configinfo['needmainPassword'] = 0;        //是否需要主持人密码
            $configinfo['isCreateUser'] = 1;            //是否为创建者本人  1：是， 0：否
            $configinfo['dangqianId'] = intval($this->auth->id);
            if ($this->auth->id != $confObj['admin_id']) {   //当入会者不是 创建者本人时

                $configinfo['isCreateUser'] = 0;
                // 是否需要会议室密码
                if ($confObj['normalPassword']) {
                    $configinfo['neednormalPassword'] = 1;
                }
                // 是否需要主持人密码
                if ($confObj['mainPassword']) {
                    $configinfo['needmainPassword'] = 1;
                }
            }

            $configinfo['mainAudio'] = (int)$confObj['mainAudio'];
            $configinfo['mainVideo'] = (int)$confObj['mainVideo'];
            $configinfo['participantVideo'] = (int)$confObj['participantVideo'];
            $configinfo['participantAudio'] = (int)$confObj['participantAudio'];
            $configinfo['normalPassword'] = $confObj['normalPassword'];
            $configinfo['conf_id'] = $confObj['serial'];
            $configinfo['startTime'] = $confObj['startTime'];
            $configinfo['stopTime'] = $confObj['endTime'];
            $configinfo['address'] = $addressInfo;
            $configinfo['name'] = $confObj['name'];
            $configinfo['confMode'] = $confObj['mode'];
            $configinfo['userId'] = $user['serial'];   //获取此会议所有者的 唯一标识符
            $configinfo['avatar'] = config("default_avatar")."?v=".time();
            $configinfo['isInterpreter'] = false;
            $configinfo['lock'] = (int)$confObj['lock'];
            $webUrl = config('windowsServer');
            $webUrl = $scheme."://".$host;
            $configinfo['webUrl'] = $webUrl;

            // 判断是否需要im信息并返回  TODO 活动目前不需要。
            $configinfo['im_account']  = null;
            $configinfo['im_userSig']  = null;
            $configinfo['im_nickname'] = null;

            $configinfo['recordType'] = '';

            // 录制
            $configinfo["recordVideo"] = config("recordVideo");
            // 邀请二维码
            $configinfo["inviteQRcode"] = config("inviteQRcode");
            // 共享文档
            $configinfo["shareDocument"] = config("shareDocument");
            // 轮询
            $configinfo["polling"] = config("polling");
            // 默认公有标准版
            $configinfo["platform"] = config("platform");
            // 网络摄像头
            $configinfo["netCamera"] = config("netCamera");
            // 分享图片
            $configinfo["share_image"] = $confObj['share_image'];
            if (!$confObj['share_image']){
                $configinfo["share_image"] = '/assets/img/share_image.png';
            }
            $configinfo["share_image"]=$confObj['share_image'];
            if (!$confObj['share_image']){
                $configinfo["share_image"] = '/assets/img/share_image.png';
            }

            if (config("conf_restrict") && !in_array($params['conf_id'],config('unlimited_conf'))){
                $info = "payment";
                // TODO 活动目前不需要。
            } else {
                $info = "entry";
            }
            $configinfo['entery_msg'] = $info;
            $configinfo['entery_txt'] = "";
            $configinfo['entery_data'] = array(
                "prompt_text"=>"",
            );

            if ($info != "entry"){
                // TODO 活动目前不需要。
                $enter_data["left_button_text"] ="取消";
                $enter_data["left_button_jump"] = "cancel";
                $configinfo['entery_data'] = $enter_data;
            }
            //pr($configinfo);
            $this->success('会议配置查询成功', $configinfo, 1);
        }
    }


    /**
     * 会议配置
     * 源 https://v.vymeet.com:443/812244054?peerName=843212379&displayName=牛呵呵&PHPSESSID=7f1hbrb05nfg37i0trr3epnlj1&token=991a0a5f-e4d3-4d63-9599-c3f6749ae371&lang=zh-CN&weburl=https://my.local-vymeet.cn
     *    https://v.vymeet.com:443/812244054?peerName=843212379&displayName=牛呵呵&PHPSESSID=m0mkc9hrmtcu8j28ne874kig31&token=95012301-c24c-467d-b065-8585deaab2ff&lang=zh-CN&weburl=https://my.local-onzoom.cn
     *
     * 回调请求本接口：
     * https://my.local-vymeet.cn/api/conference/config?conf_id=812244054&token=991a0a5f-e4d3-4d63-9599-c3f6749ae371&lang=zh-CN
     * https://my.local-onzoom.cn/api/conference/config?conf_id=812244054&token=95012301-c24c-467d-b065-8585deaab2ff&lang=zh-CN
     *
     * 1、当从后台登陆后点击加入会议 本接口传来三个参数：
     * conf_id = 812244054  会议id
     * token = 96612f38-376d-4416-a759-4446fdd4626a （如果是登陆用户，这就是user_token表里的用户tokenbu）
     * lang = zh-CN
     */
    public function config888()  //1140
    {
        $params = $this->request->param();
        if ($params) {
            $params['conf_id'] = trim($params['conf_id']);
            $serialNumber = isset($params['serialNumber']) ? str_replace(' ', '', $params['serialNumber']) : '';
            //会主表信息
            $confObj = Db::name('conference')->where('serial', $params['conf_id'])->find();
            if (!$confObj) {
                $this->error("会议不存在！");
            }
            //获取会议的所有者 信息
            $user = Db::name("admin")->where('id',$confObj['admin_id'])->find();
            if ($user['status'] != "normal") {
                $this->error("会议已失效");
            }
            if (!$user['admin_tag']){
                $user['admin_tag'] = 'null';
                $user['validity_time'] = "2000-01-01 00:00:00";         //有效期
            }
            $noSlash = isset($params['noSlash']) ? $params['noSlash'] : false;          // 是否加密：

            // 获取缓存中的剩余服务器
            $cacheType = config('cache.redis') ? 'redis' : '';
            $allServerAddress = Cache::store($cacheType)->get(config('redis_prefix').'ServerAddress'."-admin_tag-".$user['admin_tag']);
            if (!$allServerAddress) {
                $serverAddressObj = new \app\admin\model\ServerAddress;
                $allServerAddress = [];
                $user_tags_service = Db::name('server_grouping')->whereLike("tag_ids",'%'.$user['admin_tag'].'%')->find();
                $serverAddressSQLdata = $serverAddressObj->where("distinguish",$user_tags_service['id'])->select();
                if (!$serverAddressSQLdata){
//                    $serverAddressSQLdata = $serverAddressObj->distinct(true)->select();
                    $serverAddressSQLdata = $serverAddressObj->where('distinguish is null')->select();
                }
                foreach ($serverAddressSQLdata as $sqldata) {
                    $addressInfo = [];
                    $addressInfo["intranet_address"] = $sqldata['intranet_address'];
                    $addressInfo["external_address"] = $sqldata["external_address"];
                    $addressInfo["encrypted_extranet"] = $sqldata["encrypted_extranet"];
                    $addressInfo["encrypted_intrane"] = $sqldata["encrypted_intrane"];
                    $allServerAddress[] = $addressInfo;
                }
            }

            // 查询会议ID是否已分配会议地址
            $ConfServerAddress = Cache::store($cacheType)->get(config('redis_prefix').'ConfServerAddress:' . $params['conf_id']);
            if ($ConfServerAddress) {
                $seradd = $ConfServerAddress;
            } else {
                $seradd = array_shift($allServerAddress);
                Cache::store($cacheType)->set(config('redis_prefix').'ConfServerAddress:' . $params['conf_id'], $seradd, 0);
                Cache::store($cacheType)->set(config('redis_prefix').'ServerAddress'."-admin_tag-".$user['admin_tag'], $allServerAddress, 0);
            }

            $host = $this->request->host();
            $scheme = $this->get_scheme();   // 获取 https  $scheme = adminApi::get_scheme();

            if (isset($params['encrypted'])) {
                $encrypted = $params['encrypted'];
            } else {
                if ($scheme == "https") {
                    $encrypted = 1;
                } elseif ($scheme == "http") {
                    $encrypted = 0;
                } else {
                    $encrypted = 1;
                }
            }

            if (isset($params['intranet'])) {
                $intranet = $params['intranet'];
                if ($intranet == "external") {
                    if ($encrypted) {
                        $addressInfo = $seradd['encrypted_extranet'];
                    } else {
                        $addressInfo = $seradd['external_address'];
                    }
                } else {
                    if ($encrypted) {
                        $addressInfo = $seradd['encrypted_intrane'];
                    } else {
                        $addressInfo = $seradd['intranet_address'];
                    }
                }

            } else {
                // 加密
                if ($encrypted) {
                    $encryptedIntrane = explode(":", $seradd['encrypted_intrane']);
                    $encryptedIntrane = $encryptedIntrane[1];
                    $encryptedIntrane = explode("//", $encryptedIntrane);
                    $encryptedIntrane = $encryptedIntrane[1];
                    $encryptedExtranet = explode(":", $seradd['encrypted_extranet']);
                    $encryptedExtranet = $encryptedExtranet[1];
                    $encryptedExtranet = explode("//", $encryptedExtranet);
                    $encryptedExtranet = $encryptedExtranet[1];
                    if ($host == $encryptedExtranet) {
                        $addressInfo = $seradd['encrypted_extranet'];
                    } elseif ($host == $encryptedIntrane) {
                        $addressInfo = $seradd['encrypted_intrane'];
                    } else {
                        $addressInfo = $seradd['encrypted_extranet'];
                    }
                } else {  // 不加密
                    $intranetAddress = explode(":", $seradd['intranet_address']);
                    $intranetAddress = $intranetAddress[1];
                    $intranetAddress = explode("//", $intranetAddress);
                    $intranetAddress = $intranetAddress[1];
                    $externalAddress = explode(":", $seradd['external_address']);
                    $externalAddress = $externalAddress[1];
                    $externalAddress = explode("//", $externalAddress);
                    $externalAddress = $externalAddress[1];
                    if ($host == $intranetAddress) {
                        $addressInfo = $seradd['intranet_address'];
                    } elseif ($host == $externalAddress) {
                        $addressInfo = $seradd['external_address'];
                    } else {
                        $addressInfo = $seradd['external_address'];
                    }
                }
            }

            if ($noSlash == true) {
                if (substr($addressInfo, -1) == '/') {
                    $addressInfo = substr($addressInfo, 0, strlen($addressInfo) - 1);
                }
            } else {
                if (substr($addressInfo, -1) != '/') {
                    $addressInfo = $addressInfo . "/";
                }
            }

            // $configinfo   获取会议相关配置信息

            $configinfo = [];
            $configinfo['neednormalPassword'] = 0;      //是否需要会议室密码
            $configinfo['needmainPassword'] = 0;        //是否需要主持人密码
            $configinfo['isCreateUser'] = 1;            //是否为创建者本人  1：是， 0：否


            //Session::set('admin', '');
            if ($this->auth->id != $confObj['admin_id']) {   //当入会者不是 创建者本人时
                $configinfo['isCreateUser'] = 0;
                // 是否需要会议室密码
                if ($confObj['normalPassword']) {
                    $configinfo['neednormalPassword'] = 1;
                }
                // 是否需要主持人密码
                if ($confObj['mainPassword']) {
                    $configinfo['needmainPassword'] = 1;
                }
            }

              //当前用户部门、会议资料相关  TODO 活动目前不需要。
//            $depUser = Db::name("conf_department")
//                ->alias('conf_dep')
//                ->join('admin_dp admin_dp', 'conf_dep.dep_id=admin_dp.department_id',"LEFT")
//                ->where('conf_dep.conf_id',$confObj['id'])
//                ->where('admin_dp.admin_id',$this->auth->id)
//                ->find();
//            if ($depUser){
//                $configinfo['neednormalPassword'] = 0;
//            }

            //查询设备是否需要入会密码  TODO 活动目前不需要。
//            if (isset($params['deviceId'])){
//                $equipment = Db::name('conf_equipment')->alias('conf_equ')
//                    ->join('equipment equipment','equipment.id=conf_equ.equipment_id')
//                    ->where('conf_equ.conf_id',$confObj['id'])
//                    ->where("equipment.serialNumber",$params['deviceId'])
//                    ->find();
//                if ($equipment){
//                    $configinfo['neednormalPassword'] = 0;
//                }
//            }
            pr($confObj, 1);
            pr($configinfo, 1);
            $configinfo['mainAudio'] = (int)$confObj['mainAudio'];
            $configinfo['mainVideo'] = (int)$confObj['mainVideo'];
            $configinfo['participantVideo'] = (int)$confObj['participantVideo'];
            $configinfo['participantAudio'] = (int)$confObj['participantAudio'];
            $configinfo['normalPassword'] = $confObj['normalPassword'];

            $configinfo['conf_id'] = $confObj['serial'];
            $configinfo['startTime'] = $confObj['startTime'];
            $configinfo['stopTime'] = $confObj['endTime'];
            $configinfo['address'] = $addressInfo;

            $configinfo['name'] = $confObj['name'];
            $configinfo['confMode'] = $confObj['mode'];

            //$user = Db::name('admin')->where('id', $confObj['admin_id'])->find();//上面已经查询过了
            $configinfo['userId'] = $user['serial'];   //获取此会议所有者的 唯一标识符

            //用户头像 写死即可
            /*if ($this->auth->avatar){
                $configinfo['avatar'] = $this->auth->avatar;
                if (config("default_avatar") == $this->auth->avatar){
                    $configinfo['avatar'] = $this->auth->avatar."?v=".time();
                }
            }else{
                $configinfo['avatar'] = config("default_avatar")."?v=".time();
            }*/
            $configinfo['avatar'] = config("default_avatar")."?v=".time();

            // 判断当前用户是否为译员
            /*$senator = Db::name('conf_senator')->alias('conf_senator')
                ->join('senator senator','senator.id=conf_senator.sid')
                ->where('senator.admin_id',$this->auth->id)
                ->where("conf_senator.cid",$confObj['id'])
                ->find();
            if ($senator){
                $lanuage = Db::name('language')
                    ->where('id',$senator['source_language'])
                    ->whereOr('id',$senator['translate_language'])
                    ->select();
                $transLang = array();
                foreach ($lanuage as $value){
                    if ($value['id'] == $senator['source_language']){
                        array_unshift($transLang,$value['name']);
                    }else{
                        $transLang[] = $value['name'];
                    }
                }
                $configinfo['isInterpreter'] = true;
                $configinfo['transLang'] = $transLang;
            }else{
                $configinfo['isInterpreter'] = false;
            }*/
            $configinfo['isInterpreter'] = false;


            $configinfo['lock'] = (int)$confObj['lock'];
            $webUrl = config('windowsServer');
            $webUrl = $scheme."://".$host;
            $configinfo['webUrl'] = $webUrl;

            // 判断是否需要im信息并返回
            $configinfo['im_account']  = null;
            $configinfo['im_userSig']  = null;
            $configinfo['im_nickname'] = null;
            /*if ($serialNumber) {
                // 是否关联云通信
                if (Config::get('apiSwitches.im')){
                    // 获取TLS云通信的登录签名sig
                    $TLSapi = new TLSSigAPI();
                    $userSig = $TLSapi->registerIm($serialNumber);
                    if (!$userSig){
                        $userSig = null;
                    }
                }else{
                    $userSig = null;
                }
                if ($userSig) {
                    $configinfo['im_account']  = Config::get('imPrefix').$serialNumber;
                    $configinfo['im_userSig']  = $userSig;
                    $configinfo['im_nickname'] = 'Screen_'.$serialNumber;
                }
            }else{
                if ($this->auth->isLogin()) {
                    // 是否关联云通信
                    if (Config::get('apiSwitches.im')){
                        // 获取TLS云通信的登录签名sig
                        $TLSapi = new TLSSigAPI();
                        $userSig = $TLSapi->isTLS($this->auth->account_id);
                        if (!$userSig){
                            $userSig = null;
                        }
                    }else{
                        $userSig = null;
                    }
                    if ($userSig) {
                        $configinfo['im_account']  = Config::get('imPrefix').$this->auth->username;
                        $configinfo['im_userSig']  = $userSig;
                        $configinfo['im_nickname'] = $this->auth->nickname;
                    }
                }
            }*/

            // 加入录制相关会议类型参数
           /* $check_eoc_worker = Db::name('eoc_workorder')->where(['conf'=>$params['conf_id']])->field('id')->find();
            if (!empty($check_eoc_worker)) {
                $configinfo['recordType'] = 'gongdan';
            }else{
                $configinfo['recordType'] = '';
            }*/
            $configinfo['recordType'] = '';

            // 录制
            $configinfo["recordVideo"]=config("recordVideo");
            // 邀请二维码
            $configinfo["inviteQRcode"]=config("inviteQRcode");
            // 共享文档
            $configinfo["shareDocument"]=config("shareDocument");
            // 轮询
            $configinfo["polling"]=config("polling");
            // 默认公有标准版
            $configinfo["platform"]=config("platform");
            // 网络摄像头
            $configinfo["netCamera"]=config("netCamera");
            // 分享图片
            $configinfo["share_image"]=$confObj['share_image'];
            if (!$confObj['share_image']){
                $configinfo["share_image"] = '/assets/img/share_image.png';
            }
            $configinfo["share_image"]=$confObj['share_image'];
            if (!$confObj['share_image']){
                $configinfo["share_image"] = '/assets/img/share_image.png';
            }

            if (config("conf_restrict") && !in_array($params['conf_id'],config('unlimited_conf'))){
                $info = "payment";
                //TODO 。。。。
            } else {
                $info = "entry";
            }
            $configinfo['entery_msg'] = $info;
            $configinfo['entery_txt'] = "";
            $configinfo['entery_data'] = array(
                "prompt_text"=>"",
            );

            if ($info != "entry"){
                // TODO ...
                $enter_data["left_button_text"] ="取消";
                $enter_data["left_button_jump"] = "cancel";
                $configinfo['entery_data'] = $enter_data;
            }
            pr($configinfo);

            $this->success('会议配置查999询成功', $configinfo, 1);
        }
    }

    /**
     * 获取当前的访问方式：http还是https
     * @return mixed|string
     */
    public function get_scheme() {
        $scheme = 'http';
        if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']))
            $scheme = $_SERVER['HTTP_X_FORWARDED_PROTO'];
        else {
            if ( isset( $_SERVER['HTTPS'] ) ) {
                if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) {
                    $scheme = 'https';
                }
                if ( '1' == $_SERVER['HTTPS'] ) {
                    $scheme = 'https';
                }
            }
            elseif ( isset( $_SERVER['REQUEST_SCHEME'] ) ) {
                $scheme = $_SERVER['REQUEST_SCHEME'];
            }
        }
        return $scheme;
    }

}
